<template>
  <div>
    <h1>{{ stuMessage }}</h1>
    <h2>学生姓名：{{ stuName }}</h2>
    <h2>学生年龄：{{ stuAge }}</h2>
    <h2>学生性别：{{ stuSex }}</h2>
    <button @click="sendMessageName">点击按钮给School组件发送学生姓名数据</button>
  </div>
</template>

<script>
export default {
    name:"Student",
    data:function(){
        return{
            stuMessage:"student information",
            stuName:"zhangsan",
            stuAge: 23,
            stuSex:'man'
        }
    },
    methods:{
      // Student组件需要给School组件传递数据,需要在student中触发事件
      sendMessageName(){
        this.x.$emit("messageName",this.stuName)
      }
    },
    mounted(){
        //测试是否能拿到bus对象
        console.log(this.x); //Student组件的VueComponent实例对象-->VueComponent的原型对象-->vue的原型对象
    }
}
</script>


<style>

</style>